//
//  KCZYTopView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/17.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "KCZYTopView.h"

@implementation KCZYTopView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.leftImageView];
    [_leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@20);
        make.centerY.equalTo(self.mas_centerY);
        make.width.equalTo(@26);
        make.height.equalTo(@23);
    }];
    [self addSubview:self.titleLabel];
    CGFloat w1 = [PublickFunctionObject getLabelWith:_titleLabel].width+10;
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftImageView.mas_right).offset(10);
        make.centerY.equalTo(self.mas_centerY);
        make.width.equalTo(@0).offset(w1);
        make.height.equalTo(@23);
    }];
    [self addSubview:self.detailLabel];
    CGFloat w2 = [PublickFunctionObject getLabelWith:_detailLabel].width+10;
    [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(10);
        make.centerY.equalTo(self.mas_centerY);
        make.width.equalTo(@0).offset(w2);
        make.height.equalTo(@23);
    }];
//    [self addSubview:self.timeLabel];
//    CGFloat w3 = [PublickFunctionObject getLabelWith:_timeLabel].width+10;
//    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.detailLabel.mas_right).offset(10);
//        make.centerY.equalTo(self.mas_centerY);
//        make.width.equalTo(@0).offset(w3);
//        make.height.equalTo(@23);
//    }];
//    [self addSubview:self.lestLabel];
//    CGFloat w4 = [PublickFunctionObject getLabelWith:_lestLabel].width+10;
//    [_lestLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.timeLabel.mas_right).offset(10);
//        make.centerY.equalTo(self.mas_centerY);
//        make.width.equalTo(@0).offset(w4);
//        make.height.equalTo(@23);
//    }];
}
- (UIImageView *)leftImageView{
    if (!_leftImageView) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.image = [UIImage imageNamed:@"wenJian_file"];
        _leftImageView = imageView;
    }
    return _leftImageView;
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:14];
        label.text = @"慧阅读2-2-C    Lesson 25";
        label.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
        _titleLabel = label;
    }
    return _titleLabel;
}
- (UILabel *)detailLabel{
    if (!_detailLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.text = @"文件:3 大小:82.5MB";
        label.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
        label.font = [UIFont systemFontOfSize:12];
//        label.attributedText = [PublickFunctionObject getPriceAttribute:label.text and:[UIColor redColor] andChangeBenginString:@"件:" andEndString:@" " andSize:12];
        _detailLabel = label;
    }
    return _detailLabel;
}
- (UILabel *)timeLabel{
    if (!_timeLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.text = @"发放日期：2019-03-20 ";
        label.textColor = SELECTEDCOLOR;
        label.font = [UIFont systemFontOfSize:12];
        _timeLabel = label;
    }
    return _timeLabel;
}
- (UILabel *)lestLabel{
    if (!_lestLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(422,216.5,145.5,11.5);
        label.numberOfLines = 0;
        label.text = @"剩余：5/天";
        label.textColor = [UIColor redColor];
        label.font = [UIFont systemFontOfSize:12];
        _lestLabel = label;
    }
    return _lestLabel;
}

@end
